home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1993 / MacHack 1993.toast / MacHack™ 1987-1992 / MacHack™ '90 / Source Code ƒ / MPW C ƒ / C Include ƒ / CIncludesTool next >
Encoding:
Text File  |  1990-03-30  |  1.6 KB  |  75 lines  |  [TEXT/MPS ]

  1. # Script for CIncludes Tool  - by John Jeppson
  2.  
  3. set exit 0
  4. set param 0
  5. set toolStatus 0
  6.  
  7. if {#} == 1
  8.     if ("{1}" == "-m") || ("{1}" == "-M")
  9.         set param 1
  10.     else if ("{1}" == "-f") || ("{1}" == "-F")
  11.         set param 2
  12.     else if ("{1}" == "-i") || ("{1}" == "-I")
  13.         set param 3
  14.     end
  15. end
  16.         
  17. if {param} == 0
  18.     beep
  19.     echo
  20.     echo 'CIncludesTool must be called with a single parameter:'
  21.     echo '   -f  Locates selection from active window'
  22.     echo '   -m  Rebuilds the CIncludes identifier dictionary'
  23.     echo '   -i  Reformats "#include" statements in selection'
  24.     echo
  25.  
  26. else if {param} == 1
  27.     find §:/∞/ "{Active}"; find §Δ "{Active}"; echo
  28.     CIncludesCode -m `files -f {CIncludes}≈.h`
  29.     set toolStatus "{Status}"
  30.     Beep 2C,20,128
  31.  
  32. else if {param} == 2
  33.     Mark -y § x162534 "{Active}"
  34.  
  35.     set str  "`catenate "{Active}".§`"
  36.     CIncludesCode -v "{str}"
  37.     set toolStatus "{Status}"
  38.  
  39.     if {toolStatus} == 0
  40. #        find §:/∞/ "{Active}"; find §Δ "{Active}"; echo        # write to next line
  41.         find   • "{Active}"                                    # write to top of file
  42.         CIncludesCode -f "{str}"
  43.         set toolStatus "{Status}"
  44.     end
  45.     
  46.     find   x162534 "{Active}"
  47.     UnMark x162534 "{Active}"
  48.  
  49. else if {param} == 3
  50.     CIncludesCode -i "{Active}.§"
  51.     set toolStatus "{Status}"
  52. end
  53.  
  54.  
  55. if {toolStatus}
  56.     beep
  57.     echo
  58.  
  59.     if      {toolStatus} == '1'
  60.         echo 'Bad Parameters to "CIncludesCode"'    # won't occur here
  61.     else if {toolStatus} == '2'
  62.         echo 'Invalid Identifier!'
  63.     else if {toolStatus} == '3'
  64.         if ({param} == 2) || (param} == 3)
  65.             echo 'Unable to Load DataBase Resource!'
  66.         else
  67.             echo 'Out of Memory error!'
  68.         end
  69.     else if {toolStatus} == '4'
  70.         echo 'Identifier not found in CIncludes!'
  71.     end
  72.  
  73.     echo
  74. end
  75.